worker_processes 1;
events {
    worker_connections  1024;
}
# --- 软件仓库 HTTP 服务（仅master0节点包含）---
{{if eq (index .Roles.master0 0) .IP}}
http {
    server {
        listen {{.repository_port}};
        location / {
            root {{.repository_dir}};
            autoindex on;
        }
    }
}
{{end}}

# --- K8s Master LB ---
stream {
    upstream backend {
    	least_conn;
        hash $remote_addr consistent;
        {{ range $index, $value := .Roles.master }}
        server {{ $value }}:6443        max_fails=3 fail_timeout=30s;
        {{ end }}
    }
    server {
        listen 127.0.0.1:6443;
        proxy_connect_timeout 1s;
        proxy_pass backend;
    }
}